
bbox_file = '/media/handsome/data/hanson/CelebA/Anno/list_bbox_celeba.txt'
landmarks_file = '/media/handsome/data/hanson/CelebA/Anno/list_landmarks_celeba.txt'
concat_file = '/media/handsome/data/hanson/CelebA/Anno/bboxs_landmarks_celeba.txt'

f = open(concat_file, 'w')

with open(bbox_file, 'r') as f1:
    bboxs = f1.readlines()
with open(landmarks_file, 'r') as f2:
    landmarks = f2.readlines()

    for idx, _ in enumerate(landmarks):

        if idx < 2:
            continue
        landmark = landmarks[idx].strip().split(' ')
        landmark = [x for x in landmark if x != '']
        bbox = bboxs[idx].strip().split(' ')
        bbox = [x for x in bbox if x != '']
        if len(bbox) != 5 or len(landmark) != 11:
            print("error",bbox[0], landmark[0])
        if(landmark[0] == bbox[0]):
            f.write('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s \n'%
                    (bbox[0], bbox[1], bbox[2], str(int(bbox[3]) + int(bbox[1])),str(int(bbox[2]) + int(bbox[4])),
                        landmark[1], landmark[2], landmark[3], landmark[4], landmark[5], landmark[6],
                     landmark[7], landmark[8], landmark[9], landmark[10]))
f.close()